package com.cat.mediator;

/**
 * @author cat
 * @version 2025/5/27 19:39
 * @description 具体中介者
 * @since JDK17
 */

public class MediatorStructure extends Mediator {
    // 聚合房主和租客
    private HouseOwner houseOwner;
    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    @Override
    public void contact(String message, Person person) {
        if (person instanceof Tenant) {
            houseOwner.getMessage(message);
        } else {
            tenant.getMessage(message);
        }
    }
}
